package com.hxit.huaxiamelongarden.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hxit.huaxiamelongarden.domin.po.Tags;
import com.hxit.huaxiamelongarden.mapper.TagMapper;
import com.hxit.huaxiamelongarden.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName TagServiceImpl
 * @description 标签逻辑实现类
 * @Author 12694
 * @Date 2025/1/28 14:43
 * @Version 1.0
 **/
@Service
public class TagServiceImpl implements TagService {
    @Autowired
    private TagMapper tagMapper;
    //根据帖子id查找标签
    @Override
    public List<Tags> findTagByContentId(int ContentId) {
        List<Tags> tags = tagMapper.selectByContentId(ContentId);
        return tags;
    }

    //查询所有标签
    @Override
    public List<Tags> getAllTag() {
        List<Tags> tagsList = tagMapper.selectList(null);
        return tagsList;
    }

    //根据标签名查询标签
    @Override
    public Tags findTagByTagName(String tagName) {
        LambdaQueryWrapper<Tags> queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(Tags::getTagName,tagName);
        Tags tag = tagMapper.selectOne(queryWrapper);
        return tag;
    }
}
